/*
 * @Author: scopesang
 * @Date: 2022-05-12 17:57:26
 * @LastEditors: scopesang
 * @LastEditTime: 2022-05-12 18:17:57
 * @FilePath: \hook-ts\src\reduxApp.tsx
 * @Description: 
 * 
 * Copyright (c) 2022 by scopesang/大鹏科技, All Rights Reserved. 
 */
import React from 'react'
// 高阶函数链接器  高阶函数 双括号
import { connect } from 'react-redux'
import { Dispatch } from 'redux'

interface Istate {
    num: number,
    increaseFn: () => void
}
const reduxApp = (props: Istate) => {
    return (
        <div>
            <div> {props.num}</div >
            <button onClick={props.increaseFn} >累加</button>
        </div>
    )
}

const mapStateToProps = (state: Istate) => {
    return {
        num: state.num
    }

}

// : (arg0: { type: string; value: string }) => void
const mapdispatchToProps = (dispatch: Dispatch) => {
    return {
        increaseFn() {
            dispatch({
                type: 'increase',
                value: "1"
            })
        }
    }


}


//两个映射
// (state映射,dispath映射)()
export default connect(mapStateToProps, mapdispatchToProps)(reduxApp) 
